
    <!DOCTYPE html>
    <html lang="zh-CN">
    <head>
      <meta charset="UTF-8">
      <meta name="viewport" content="width=device-width, initial-scale=1.0">
      <title>Spring常用注解有哪些 - 学习卡片</title>
      <style>
        body { font-family: sans-serif; background-color: #f0f8ff; color: #333; display: flex; flex-direction: column; align-items: center; padding: 50px 20px; }
        .header h1 { font-size: 32px; }
        .grid-container { display: grid; grid-template-columns: repeat(3, 1fr); gap: 28px; width: 100%; max-width: 1200px; }
        .card-container { perspective: 1200px; cursor: pointer; height: 250px; }
        .card { width: 100%; height: 100%; position: relative; transform-style: preserve-3d; transition: transform 0.7s; border-radius: 16px; box-shadow: 0 4px 16px rgba(0,0,0,0.08); }
        .card-container.flipped .card { transform: rotateY(180deg); }
        .card-face { position: absolute; width: 100%; height: 100%; backface-visibility: hidden; display: flex; flex-direction: column; box-sizing: border-box; border-radius: 16px; background-color: #fff; padding: 24px; }
        .card-back { background-color: #f0fff4; transform: rotateY(180deg); justify-content: space-between; }
        .card-category { font-size: 14px; color: #0052d9; margin-bottom: 8px; font-weight: 500; }
        .card-question { font-size: 20px; font-weight: 500; flex-grow: 1; display: flex; align-items: center; justify-content: center; text-align: center; }
        .card-answer-wrapper { flex-grow: 1; overflow-y: auto; }
        .card-answer { font-size: 15px; line-height: 1.7; }
        .card-footer { font-size: 13px; color: #8a919f; border-top: 1px solid #f0f0f0; padding-top: 16px; margin-top: 16px; }
        .card-source { font-size: 13px; color: #8a919f; border-top: 1px solid #f0f0f0; padding-top: 12px; margin-top: 12px; }
      </style>
    </head>
    <body>
      <div class="header">
        <h1>Spring常用注解有哪些 - 学习卡片</h1>
      </div>
      <div class="grid-container">
        
    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">机制</div>
          <div class="card-question">在Spring中，@Autowired注解可以在哪些地方使用来实现依赖的自动装配？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">机制</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">可以使用在构造函数、属性或方法上。Spring会自动解析并注入对应的依赖项。</div>
          </div>
          <div class="card-source">来源: 1. @Autowired</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">模式</div>
          <div class="card-question">在Spring分层架构中，@Controller、@Service 和 @Repository 注解通常分别用于标识哪一层的组件？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">模式</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">@Controller 用于标识Spring MVC的控制器组件（表现层）；@Service 用于标识服务组件（业务逻辑层）；@Repository 用于标识数据访问组件（数据访问层）。</div>
          </div>
          <div class="card-source">来源: 3. @Controller, 4. @Service, 5. @Repository</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">技术</div>
          <div class="card-question">当需要将HTTP请求的URL路径中的变量（如用户ID）绑定到控制器方法的参数上时，应该使用哪个注解？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">技术</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">应该使用 @PathVariable 注解，它可以将 URL 中的参数绑定到方法的参数。</div>
          </div>
          <div class="card-source">来源: 8. @PathVariable</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">机制</div>
          <div class="card-question">@RequestBody 和 @ResponseBody 注解在处理Web请求时有什么区别？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">机制</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">@RequestBody 用于将HTTP请求的主体部分（如JSON数据）绑定到方法的参数；而 @ResponseBody 用于将方法的返回值直接写入HTTP响应的主体部分，常用于返回JSON或XML格式的数据。</div>
          </div>
          <div class="card-source">来源: 9. @RequestBody, 10. @ResponseBody</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">技术</div>
          <div class="card-question">当存在多个相同类型的Bean时，如何配合@Autowired精确指定要注入哪一个Bean？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">技术</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">可以配合使用 @Qualifier 注解，通过指定要注入的Bean的名称或限定符来进行选择。</div>
          </div>
          <div class="card-source">来源: 13. @Qualifier</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">特性</div>
          <div class="card-question">如何在Spring应用中实现根据不同的环境（如开发环境、生产环境）来选择性地加载Bean？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">特性</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">使用 @Profile 注解。该注解可以根据当前激活的环境配置来决定是否加载某个Bean或配置类。</div>
          </div>
          <div class="card-source">来源: 14. @Profile</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">特性</div>
          <div class="card-question">Spring框架中用于启用方法结果缓存，从而提高执行效率的注解是什么？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">特性</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">使用 @Cacheable 注解。它可以缓存方法的返回值，提高方法的执行效率。</div>
          </div>
          <div class="card-source">来源: 16. @Cacheable</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">技术</div>
          <div class="card-question">如何将配置文件中的属性值（例如 `app.property1`）直接注入到一个Java类的字段中？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">技术</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">可以使用 @Value 注解（例如 @Value("${property.key}")）将属性值直接注入到变量中，或者使用 @ConfigurationProperties 注解将配置文件中的属性值绑定到Bean的属性上。</div>
          </div>
          <div class="card-source">来源: 12. @Value, 26. @ConfigurationProperties</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">机制</div>
          <div class="card-question">如果希望一个方法在Spring Bean完全初始化完成后立即执行，应该使用哪个注解？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">机制</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">应该使用 @PostConstruct 注解，它用于在 Bean 初始化完成后执行指定的方法。</div>
          </div>
          <div class="card-source">来源: 20. @PostConstruct</div>
        </div>
      </div>
    </div>

      </div>
    </body>
    </html>
